//
//  NewestMiddleView.m
//  livingDesign
//
//  Created by dlios on 15-1-29.
//  Copyright (c) 2015年 怡居. All rights reserved.
//

#import "NewestMiddleView.h"
#import "NewestMiddleCollectionViewCell.h"
#import "NewestDetailViewController.h"

@implementation NewestMiddleView
- (void)dealloc
{
    [_arr release];
    [_collectView release];
    [_newest release];
    [_flowLayout release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.arr = [NSMutableArray array];
//        self.backgroundColor = [UIColor whiteColor];
        
        self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
        self.flowLayout.itemSize = CGSizeMake((self.frame.size.width - 45) / 2, 200);
//        self.flowLayout.minimumInteritemSpacing = 15;
        self.flowLayout.minimumLineSpacing = 15;
        self.flowLayout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
        [self.flowLayout release];
        
        self.collectView = [[UICollectionView alloc] initWithFrame:self.bounds collectionViewLayout:self.flowLayout];
        self.collectView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.collectView];
//        self.collectView.delegate = self;
//        self.collectView.dataSource = self;
         [self.collectView registerClass:[NewestMiddleCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    }
    return self;
}
//- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    NewestDetailViewController *newest = [[NewestDetailViewController alloc] init];
////    [self presentViewController:newest animated:YES completion:^{
////        
////    }];
//}
//
//// 协议方法
//- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
//{
//    return self.arr.count;
//}
//- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
//{
//    NewestMiddleCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
//    cell.newest = [self.arr objectAtIndex:indexPath.item];
////    cell.backgroundColor = [UIColor yellowColor];
//    return cell;
//}
//
//- (void)setArr:(NSMutableArray *)arr
//{
//    _arr = arr;
//    [self.collectView reloadData];
//}
//

@end
